<template>
  <div>
    <el-card>
      <el-form
        :inline="true"
        :model="query"
        label-width="100px"
        size="small"
      >
        <!-- 关键词检索 -->
        <el-form-item>
          <span> 公司名称：</span>
          <el-form-item class="query-form-item">
            <el-input
              v-model="query.companyName"
              placeholder="请输入公司名称"
              prefix-icon="el-icon-search"
              clearable
              style="magrin-left: 30px"
            ></el-input>
          </el-form-item>
        </el-form-item>
        <!-- 查询框 -->
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-refresh"
            @click="onRest"
          ></el-button>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="onSubmit"
          >搜索</el-button>
        </el-form-item>
      </el-form>
      <!-- table表单 -->
      <el-table
        ref="singleTable"
        :data="tableData"
        v-loading="loading"
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          type="index"
          align="center"
          width="50"
          fixed
        >
        </el-table-column>
        <el-table-column
          prop="userid"
          align="center"
          label="商城ID"
        />
        <el-table-column
          prop="usermobile"
          align="center"
          label="商城手机号"
        />
        <el-table-column
          prop="enterprisename"
          align="center"
          label="商城公司名称"
        />
        <el-table-column
          prop="registrationnumber"
          align="center"
          label="社会统一信用码"
        ></el-table-column>

        <el-table-column
          align="center"
          label="操作"
          width="200"
          fixed="right"
        >
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="auditPass(scope.row)"
            >添加到新增公司创始人</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        class="pagination-container"
        background
        :page-size="query.page.pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total,sizes,prev, pager, next, jumper"
        :current-page="query.page.currentPage"
        :page-sizes="[5, 10, 20, 30, 50]"
        :total="totalNumber"
      ></el-pagination>
    </el-card>
  </div>
</template>
<script>
import { getOriginList } from '../../api/handWork/handWorkList'
export default {
  data() {
    return {
      tableData: [],
      query: {
        page: {
          currentPage: 1,
          pageSize: 5,
        },
        companyName: '',
      },
      totalNumber: 0,
      loading: false,
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      getOriginList(this.query)
        .then((res) => {
          console.log(res, '创始人列表数据')
          if (res.code != 0) {
            this.$message.error(res.message)
            this.loading = false
            return false
          }
          this.loading = false
          this.totalNumber = res.data.totalNumber
          this.tableData = res.data.list
        })
        .catch(() => {
          this.loading = false
          this.tableData = []
        })
    },
    //搜索
    onSubmit() {
      this.query.page.currentPage = 1
      this.getList()
    },
    auditPass(row) {
      this.$router.push({
        name: '新增品牌公司',
        params: { type: '2', val: row },
      })
    },
    //刷新
    onRest() {
      this.query = {
        companyName: '',
        page: {
          currentPage: 1,
          pageSize: 5,
        },
      }
      this.getList()
    },
    handleSizeChange(val) {
      this.query.page.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.query.page.currentPage = val
      this.getList()
    },
  },
}
</script>

